package com.Mapper;

import com.Entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {
    @Select("select * from user")
    List<User> all();

    @Select("select * from user where id = #{id} and password = #{password}")
    User byIdAndPw();

    @Select("select * from user where id = #{id} ")
    User byId();

    @Insert("insert into user(id, name, password, phone, sex, isVip, birthday, registrationTime) " +
            "VALUES(#{id}, #{name}, #{password}, #{phone}, #{sex}, #{isVip}, #{birthday}, #{registrationTime})")
    int insert(User user);

    @Update("UPDATE user SET name = #{name}, phone = #{phone}, sex = #{sex}, birthday = #{birthday} WHERE id = #{id}")
    int updateGeneralInfo(User user);

    @Update("UPDATE user SET password = #{password} WHERE id = #{id}")
    int updatePassword(User user);

    @Update("UPDATE user SET isVip = #{isVip} WHERE id = #{id}")
    int updateVip(User user);

    @Delete("DELETE FROM user WHERE id = #{id}")
    int delete(User user);
}
